package com.example.demo.request;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class SQLiteJDBC {
    private static final String URL = "jdbc:sqlite:/var/www/html/data/database.db";

    public static void createTable() {
        // 合并后的 users 表结构，包含用户的所有信息字段
        String createUsersTableSQL = "CREATE TABLE IF NOT EXISTS users (" +
                "id INTEGER PRIMARY KEY AUTOINCREMENT," +
                "username TEXT NOT NULL UNIQUE," +
                "password TEXT NOT NULL," +
                "avatar TEXT," +      // 用户头像
                "name TEXT," +        // 用户姓名
                "email TEXT," +       // 用户邮箱
                "phone TEXT," +       // 用户电话
                "address TEXT);";     // 用户地址

        try (Connection conn = DriverManager.getConnection(URL);
             Statement stmt = conn.createStatement()) {
            // 创建合并后的 users 表
            stmt.execute(createUsersTableSQL);
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }
}
